# for this class, you will be using the iris and mtcars datasets # TASK 1 # descriptive statistics -------------------------------------------------- # Use the summary(), mean(), sd(),... function to summarize the iris dataset. Subset the dataframe for the different species # such that you obtain, for example, mean +/- standard deviation of Sepal Length for the three different iris species. # Next, plot a histogram to inspect the distribution of, for example, Petal Width for the three different species. # Explore the libraries pastecs (pastecs:stat.desc) and psych (psych:describeBy) for a number of descriptive statistics. # TASK 2 # correlation ------------------------------------------------------------- # First plot Sepal Length against Sepal Width for iris setosa. # Next, plot histograms and use Shapiro's Test for normality to check for normal # distribution of Sepal Length and Sepal Width of iris setosa. Normal distribution of data is an important assumption. # Use cor and cor.test to explore the correlation between sepal length and width for I. setosa. # explore psych:pairs.panels # TASK 3 # tests for differences in means ------------------------------------------ # Generally, t-tests are used to compare differences between two groups. ANOVA is used to compare differences among more than two groups. # Use t-tests to test for statistical significance of differences in sepal length between Iris setosa and Iris versicolor. # First use boxplot() for visualization of sepal length of I. setosa and I. versicolor. # Check for normal distribution # An important assumption for t-tests is the homogeneity of variance of the two datasets. Use var.test() to check for homoscedasticity. # Finally, use t.test() to check for statistical significance of the difference in in sepal length between Iris setosa and Iris versicolor. # Use ANOVA to test for differences in sepal length of the three iris species. Check online for ANOVA in R. Hint: aov # USe boxplot to visualize sepal length of the three iris species. # TASK 4 # linear models ----------------------------------------------------------- # We use the mtcars dataset. Use descriptive statistics and associated visualizations to explore this dataset. # Linear regressions are a special form of linear models. In R, linear models are formalized like this: lm(x~Y), which could be tranlated to: "X depends on Y". # Follow the mod<-lm(X~Y) to build a first linear model between mpg (miles per gallon) and hp (horsepower) # Use summary(mod) to inspect model outputs. Check online for interpretation. # Check online for visualization of the model result. Hint: abline()